<?php

namespace App\Http\Resources;

class GroupUser extends User
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        $userId = request()->user()->id;
        return array_merge(parent::toArray($request), [
            'copper' => $this->copper,
            'can_remove' => $request->route('group')->user_id == $userId && $this->id != $userId,
            'bet' => $this->join_count,
            'win' => format_percentage($this->win_count, $this->join_count),
        ]);
    }
}
